﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Autofac;
using ComputerVision.Common;
using ComputerVision.Data;
using ComputerVision.Services;

namespace ComputerVision.UserControls
{
    public partial class ucBaoCaoXeTrongBai : UserControl
    {
        private IService<XeTemp> _xe;
        private FileUtil fileUtil;
        public ucBaoCaoXeTrongBai()
        {
            InitializeComponent();
            fileUtil = new FileUtil();
            _xe = Program.Container.Resolve<IService<XeTemp>>();
            xeTempBindingSource.DataSource = _xe.ToList();
        }

        private void dgvData_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvData.RowCount == 0) return;

            try
            {
                if (dgvData.Rows[e.RowIndex].Cells[10].Value.ToString().Contains(@"\"))
                {
                    picVaoTruoc.Load(fileUtil.GenerateLink("ANHVAO", dgvData.Rows[e.RowIndex].Cells[10].Value.ToString()));
                }
                else
                {
                    picVaoTruoc.Load(fileUtil.GenerateOldLink("ANHVAO", dgvData.Rows[e.RowIndex].Cells[10].Value.ToString()));

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            try
            {
                if (dgvData.Rows[e.RowIndex].Cells[11].Value.ToString().Contains(@"\"))
                {
                    picVaoSau.Load(fileUtil.GenerateLink("ANHVAO", dgvData.Rows[e.RowIndex].Cells[11].Value.ToString()));
                }
                else
                {
                    picVaoSau.Load(fileUtil.GenerateOldLink("ANHVAO", dgvData.Rows[e.RowIndex].Cells[11].Value.ToString()));

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }


    }
}
